<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .data_content {
            width: 50%;
        }

        .data_content div {
            font-size: 22px;
            line-height: 40px;
            height: 40px;
        }
        .sensor{display: flex; justify-content: flex-start;margin-left: 30%}
        .senso_item{width: 200px; align-self: center}
    </style>
</head>

<body>
    <div class="data_content">
        <div style="margin-left: 30%"><pre>网关：{$data['gateway_id']}</div>
        {foreach name="data['data']" item='vo'}
        <div class="sensor">
            <div class="senso_item"><pre>{$vo.sensor_name}传感器</div>
            <div><pre>数值：</div>
            <div><pre><span data-sensor="{$vo['mac_id']}">{$vo.data}</span></div>
        </div>
        
        {/foreach}
    </div>
</body>
<script src="/static/home/js/jquery-3.4.1.min.js"></script>
<script>
    setInterval(function () {
        $.post("{:url('data')}", {}, function (res) {
            $("div span").each(function (i, obj) {
                let sensor = $(this).data('sensor');
                $(this).text(res[sensor]);
            });
        });
    }, 1000);
</script>

</html>